package com.ctshk.app.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.system.dto.MainDataCollectionPlaceDTO;
import com.ctshk.rpc.system.req.*;
import com.ctshk.rpc.system.service.IMainDataCollectionPlaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import java.util.List;

/**
 * <p>
 * 集散地點 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-10
 */
@Api(value="集散地點", tags="集散地點")
@RestController
@RequestMapping("/main/data/collection/place")
public class MainDataCollectionPlaceController extends BaseController {

    @DubboReference
    private IMainDataCollectionPlaceService mainDataCollectionPlaceService;


    @ApiOperation(value="新增集散地點", notes="")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增", operDesc = "新增集散地點")
    @PostMapping("/add")
    public Result addCollectionTouristType(@RequestBody MainDataCollectionPlaceAddReq req){
        return  mainDataCollectionPlaceService.add(req,getCurrentUser(getRequest()));

    }

    @ApiOperation(value="查詢集散地點", notes="")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查詢", operDesc = "查詢集散地點")
    @PostMapping("/query")
    public Result<MainDataCollectionPlaceDTO> query(@RequestBody MainDataCollectionPlaceIdReq req){
        return  Result.success(mainDataCollectionPlaceService.query(req));
    }

    @ApiOperation(value="修改集散地點", notes="")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "編輯", operDesc = "修改集散地點")
    @PostMapping("/update")
    public Result update(@RequestBody MainDataCollectionPlaceUpdateReq req){
        return  mainDataCollectionPlaceService.update(req,getCurrentUser(getRequest()));

    }

    @ApiOperation(value="查詢集散地點列表", notes="")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查詢", operDesc = "查詢集散地點")
    @PostMapping("/list")
    public Result<PageResponse<MainDataCollectionPlaceDTO>> list(@RequestBody MainDataCollectionPlaceListReq req) {
        return Result.success(mainDataCollectionPlaceService.list(req));
    }

    @ApiOperation(value="(内部接口)根據區域ID查詢集散地點列表", notes="")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查詢", operDesc = "查詢集散地點")
    @GetMapping("/query/{areaId}")
    public Result<List<MainDataCollectionPlaceDTO>> queryList(@PathVariable Long  areaId){
        return  Result.success(mainDataCollectionPlaceService.queryList(areaId));
    }



}
